package com.zshan.clinic.admin.mapper.stock;


import com.zshan.clinic.admin.entity.medical.stock.StockDrugResult;
import com.zshan.clinic.admin.entity.medical.stock.DrugOut;
import com.zshan.clinic.admin.entity.vo.StockDrugDetailVo;
import com.zshan.clinic.admin.entity.vo.StockDrugTransVo;
import com.zshan.clinic.admin.entity.vo.StockWarningVo;
import com.zshan.clinic.database.model.StockDrug;
import com.zshan.clinic.database.model.StockDrugDetail;
import com.zshan.clinic.database.model.StockDrugTrans;
import com.zshan.clinic.mybatis.SuperMapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface SpecStockDrugMapper extends SuperMapper {

    /**
     * 批量添加入库记录
     * @param stockDrugInList
     */
    void addDrugTransBatch(@Param("transList") List<StockDrugTrans> stockDrugInList);

    /**
     * 批量添加库存明细
     * @param stockDrugDetailList
     */
    void addDrugDetailBatch(@Param("detailList") List<StockDrugDetail> stockDrugDetailList);

    /**
     * 查询药品库存明细数量
     * @param clinicId
     * @param drugId
     * @param storageId
     * @return
     */
    Long getStockDrugDetailCount(@Param("clinicId") Long clinicId,
                                 @Param("drugId") Long drugId,
                                 @Param("storageId") Long storageId);

    /**
     * 查询药品库存明细列表
     * @param clinicId
     * @param drugId
     * @param storageId
     * @param offset
     * @param limit
     * @return
     */
    List<StockDrugDetailVo> getStockDrugDetailList(@Param("clinicId") Long clinicId,
                                                   @Param("drugId") Long drugId,
                                                   @Param("storageId") Long storageId,
                                                   @Param("offset") Integer offset,
                                                   @Param("limit") Integer limit);

    /**
     * 库存变动流水
     * @param clinicId
     * @param drugId
     * @param storageId
     * @return
     */
    Long getStockDrugTransCount(@Param("clinicId") Long clinicId,
                                @Param("drugId") Long drugId,
                                @Param("storageId") Long storageId);

    /**
     * 库存变动流水
     * @param clinicId
     * @param drugId
     * @param storageId
     * @param offset
     * @param limit
     * @return
     */
    List<StockDrugTransVo> getStockDrugTransList(@Param("clinicId") Long clinicId,
                                                 @Param("drugId") Long drugId,
                                                 @Param("storageId") Long storageId,
                                                 @Param("offset") Integer offset,
                                                 @Param("limit") Integer limit);

    /**
     * 查询库存总表
     * @param drugOutList
     * @return
     */
    List<StockDrugResult> getStockDrugListByDrugOut(@Param("list") List<DrugOut> drugOutList);

    /**
     * 查询库存明细
     * @param drugOutList
     * @return
     */
    List<StockDrugDetail> getStockDetailListByDrugOut(@Param("list") List<DrugOut> drugOutList);

    void updateStockDrugDetailBatch(@Param("list") List<StockDrugDetail> updateStockDrugDetailList);

    void batchUpdateStockDrug(@Param("list") List<StockDrugResult> stockDrugList);

    /**
     * 库存不足预警
     * @return
     */
    List<StockWarningVo> getStockWarningList();
}
